package tech.pdai.springframework.condition;

import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.env.Environment;
import org.springframework.core.type.AnnotatedTypeMetadata;

public class LinuxCondition implements Condition {

    @Override
    public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {
        // 获取到环境信息
        Environment environment = context.getEnvironment();

        // 获取操作系统
        String property = environment.getProperty("os.name");
        return property != null && property.toLowerCase().contains("linus");
    }
}
